scale: Allocate the value next to the slider
authorTimm Bäder <mail@baedert.org>
Tue, 1 Aug 2017 09:34:23 +0000 (11:34 +0200)
committerTimm Bäder <mail@baedert.org>
Tue, 1 Aug 2017 09:36:03 +0000 (11:36 +0200)
... when vertical. Also fixes usage of the uninitialized value_alloc.y.

gtk/gtkscale.c

index 28431e77ec85355d9cfcf46b566ad42450aded70..97cd1278000a78ebcb80f2f6e7ed5e9813015291 100644 (file)
@@ -359,13 +359,11 @@ gtk_scale_allocate_value (GtkScale      *scale,
 
         case GTK_POS_TOP:
           value_alloc.x = slider_alloc.x + (slider_alloc.width - value_alloc.width) / 2;
-          value_alloc.x = CLAMP (value_alloc.x, range_alloc.x, range_alloc.x + range_alloc.width - value_alloc.width);
           value_alloc.y = 0;
           break;
 
         case GTK_POS_BOTTOM:
           value_alloc.x = slider_alloc.x + (slider_alloc.width - value_alloc.width) / 2;
-          value_alloc.x = CLAMP (value_alloc.x, range_alloc.x, range_alloc.x + range_alloc.width - value_alloc.width);
           value_alloc.y = range_alloc.height - value_alloc.height;
           break;
 
@@ -374,18 +372,18 @@ gtk_scale_allocate_value (GtkScale      *scale,
           break;
         }
     }
-  else
+  else /* VERTICAL */
     {
       switch (priv->value_pos)
         {
         case GTK_POS_LEFT:
           value_alloc.x = 0;
-          value_alloc.y = CLAMP (value_alloc.y, range_alloc.y, range_alloc.y + range_alloc.height - value_alloc.height);
+          value_alloc.y = (slider_alloc.y + (slider_alloc.height / 2)) - value_alloc.height / 2;
           break;
 
         case GTK_POS_RIGHT:
           value_alloc.x = range_alloc.width - value_alloc.width;
-          value_alloc.y = CLAMP (value_alloc.y, range_alloc.y, range_alloc.y + range_alloc.height - value_alloc.height);
+          value_alloc.y = (slider_alloc.y + (slider_alloc.height / 2)) - value_alloc.height / 2;
           break;
 
         case GTK_POS_TOP: